<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <a href="https://www.baidu.com/">点我</a>

    <script>
        let a = document.getElementsByTagName('a')[0];

        a.addEventListener('click',function(event){
            //a本身跳转的事件时默认事件
            //如何阻止默认事件
            event.preventDefault();
            alert(0)//自定义事件
        })
    </script>
</body>
</html>